import React from "react";
import { Routes, Route } from "react-router-dom";
import routes from "../../modules";

console.log(
  'background: #1890ff; color: white; padding: 2px 4px; border-radius: 2px;',  // 第一个%c对应的样式
  'color: #666; font-weight: bold;'  // 第二个%c对应的样式
)
const AppRoutes: React.FC = () => {
  const renderRoutes = (routes: any[]) => {
    return routes.map((route) => {
      const RouteElement = route.element;
      return (
        <Route
          key={route.key}
          path={route.path} // 移除前缀，让主应用处理路由
          element={RouteElement ? <RouteElement /> : null}
        >
          {route.children && renderRoutes(route.children)}
        </Route>
      );
    });
  };
  return (
      <Routes>
        {/* <Route index element={<Navigate to="/device/energy/strategy-list" />} /> */}
        {renderRoutes(routes)}
      </Routes>
  );
};

export default AppRoutes;
